<?php
/* @var $this BookingsController */
/* @var $model Bookings */
/* @var $form CActiveForm */
?>

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'bookings-form',
	'enableClientValidation'=>true,
        'clientOptions'=> array('validateOnSubmit'=>true,
                                 'beforeValidate'=>'js:function(){'
                                 
                               .'var data = "url=http://vietjetair-nduc1888.rhcloud.com/ajax_VNairlines.php&RoundTrip=" + $(":radio:checked").val() + '
                               .'"&Origin1=" +"SGN" + "&Destination1=" + "HAN" +'
                                .'"&_time1=" + $("#departing_date").val() + "&_time2=" + $("#arriving_date").val() +' 
                                .'"&traveler=" + $("#numof_adults").val() + "&baby=" + $("#numof_childrens").val() + "&newborn=" + $("#numof_baby").val();'
                                .'alert(data);'
                                .'$.ajax({'
                                        .'url : "/banvemaybay/BanVeMayBay/index.php/bookings/proxy",'
                                        .'data : data,'
                                        .'type : "POST",'
                                        .'success : function(data, textStatus, jqXHR) {'
                                                .'console.log("Success " + data);'
                                                .'$("#Bookings_trangthai").val($(":radio:checked").val());'
                                                .'$("#Bookings_storeJson").val(data);'
                                                .'$("#Bookings_diemdi").val($("#Bookings_depart_airport_code").val());'
                                                .'$("#Bookings_diemden").val($("#arive_airport_code").val());'
                                                .'$("#Bookings_ngaydi").val($("#departing_date").val());'
                                                .'$("#Bookings_ngayve").val($("#arriving_date").val());'
                                                .'$("#Bookings_nguoilon").val($("#numof_adults").val());'
                                                .'$("#Bookings_treem").val($("#numof_childrens").val());'
                                                .'$("#Bookings_sosinh").val($("#numof_baby").val());'
                                                .'$("#bookings2-form").submit();'
                                        .'},'
                                        
                                .'});'
                                . '}',
            
                                        
                                ),

)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	
       <div class="row">
                <label></label>
                <?php echo CHtml::radioButtonList('stt', '0', array('0'=>'Một chiều','1'=>'Khứ hồi'),array('separator'=>'', 'labelOptions'=>array('style'=>'text-align: left;width: 100px; padding-left:3px;padding-top:2px'))); ?>
	</div>
	<div class="row">
		<?php echo CHtml::label("depart_airport_code", "depart_airport_code"); ?>
		<?php echo $form->dropDownList($model,'depart_airport_code', CHtml::listData(Airports::model()->findAllBySql('select airport_code,airport_name from airports order by airport_name'),'airport_code','airport_name')); ?>
		<?php echo $form->error($model,'depart_airport_code'); ?>
	</div>

	<div class="row">
		<?php echo CHtml::label("arive_airport_code", "arive_airport_code"); ?>
		<?php echo CHtml::dropDownList('arive_airport_code','0', CHtml::listData(Airports::model()->findAll(),'airport_code','airport_name')); ?>
	</div>
        <div class="row">
	<label>Ngày đi:</label>
	<?php
	$this->widget('zii.widgets.jui.CJuiDatePicker',array(
	    'name'=>'departing_date',
	    // additional javascript options for the date picker plugin
	    'options'=>array(
            'minDate'=>0,
	        'showAnim'=>'clip',
	        'dateFormat'=>'dd/mm/yy',//'slide','fold','slideDown','fadeIn','blind','bounce','clip','drop'
	    ),
	    'htmlOptions'=>array(
	        'style'=>'height:20px;',
	    ),
	));
	?>
        </div>
        <div class="row">
	<label>Ngày về:</label>
	<?php
	$this->widget('zii.widgets.jui.CJuiDatePicker',array(
	    'name'=>'arriving_date',
	    // additional javascript options for the date picker plugin
	    'options'=>array(
            'minDate'=>0,
	        'showAnim'=>'clip',
	        'dateFormat'=>'dd/mm/yy',//'slide','fold','slideDown','fadeIn','blind','bounce','clip','drop'
	    ),
	    'htmlOptions'=>array(
	        'style'=>'height:20px;',
	    ),
	));
	?>
        </div>
        
        <div class="row">
                <label>Người lớn</label>
		<?php echo CHtml::dropDownList('numof_adults','0',array(0=>'0',1=>'1',2=>'2',3=>'3',4=>'4',5=>'5',6=>'6',7=>'7',8=>'8',9=>'9',10=>'10'));
		?>
		
	</div>
        <div class="row">
		<label>Trẻ em</label>
		<?php echo CHtml::dropDownList('numof_childrens','0',array(0=>'0',1=>'1',2=>'2',3=>'3',4=>'4',5=>'5',6=>'6',7=>'7',8=>'8',9=>'9',10=>'10'));
		?>
	</div>
        <div class="row">
		<label>Sơ sinh</label>
		<?php echo CHtml::dropDownList('numof_baby','0',array(0=>'0',1=>'1',2=>'2',3=>'3',4=>'4',5=>'5',6=>'6',7=>'7',8=>'8',9=>'9',10=>'10'));
		?>
	</div>
	
        
	<div class="row buttons">
           
            <?php echo CHtml::submitButton('asd');?>
            <label id="result"></label>
	</div>

<?php $this->endWidget(); ?>
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'bookings2-form',
	'enableClientValidation'=>FALSE,
)); ?>
         <div class="row">
             <input type="hidden" value="" name="Bookings[trangthai]" id="Bookings_trangthai" />
             <input type="hidden" value="" name="Bookings[storeJson]" id="Bookings_storeJson" />
             <input type="hidden" value="" name="Bookings[nguoilon]" id="Bookings_nguoilon" />
             <input type="hidden" value="" name="Bookings[treem]" id="Bookings_treem" />
             <input type="hidden" value="" name="Bookings[sosinh]" id="Bookings_sosinh" />
             <input type="hidden" value="" name="Bookings[ngaydi]" id="Bookings_ngaydi" />
             <input type="hidden" value="" name="Bookings[ngayve]" id="Bookings_ngayve" />
             <input type="hidden" value="" name="Bookings[diemdi]" id="Bookings_diemdi" />
             <input type="hidden" value="" name="Bookings[diemden]" id="Bookings_diemden" />
	</div>
<?php $this->endWidget(); ?>
</div><!-- form -->